package consumer.strategy;

import consumer.handler.Router;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;

/**
 * @ClassName PollingRouterStrategy
 * @Description
 * @Author Jingxiao.Ye
 * @Date 2022/1/16 下午4:45
 * @Version V1.0
 * @Since JDK 11
 */
public class PollingRouterStrategy implements RouterStrategy {

    private AtomicInteger atomicInteger;

    @Override
    public String getRouter(List<String> urls) {
        if(urls.size() == 0) return null;
        return urls.get(atomicInteger.getAndIncrement() % urls.size());
    }
}
